﻿using System.Drawing;
using System.Drawing.Drawing2D;

namespace WindowsFormsApplication1
{
    public class BrushContainer
    {
        Color color;

        public Color Color
        {
            get { return color; }
            set
            {
                if (color == value)
                    return;
                if (Brush != null)
                    Brush.Dispose();
                Brush = new SolidBrush(color);
            }
        }

        public Brush Brush { get; private set; }

        public BrushContainer(Color color)
        {
        }
    }

    public class PenContainer
    {
        Color color;
        float lineWidth;

        public Color Color
        {
            get { return color; }
            set
            {
                if (color == value)
                    return;
                color = value;
                RecreatePen();
            }
        }

        public float LineWidth
        {
            get { return lineWidth; }
            set
            {
                if (lineWidth == value)
                    return;
                Pen.Width = lineWidth = value; ;
            }
        }

        public Pen Pen { get; private set; }

        public PenContainer(Color color)
        {
            Color = color;
        }

        void RecreatePen()
        {
            if (Pen != null)
                Pen.Dispose();
            Pen = new Pen(color, lineWidth);
        }
    }
}
